﻿


<div ms-controller="tmpmodelview">
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>城市：</label>
        <div class="controls">
            <select class="input-medium input-xfat" ms-duplex="modelData.Client">
                <option ms-repeat-el="ClientList" ms-attr-value="el.ID">{{el.CodeName}}</option>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"><b style="color: #f00;">*</b>分类：</label>
        <div class="controls">
            <select class="input-medium input-xfat" ms-duplex="modelData.Type1">
                <option value="1">首页</option>
            </select>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            <b style="color: #f00;">*</b>
            广告标题：
        </label>
        <div class="controls">
            <input type="text" name="schoolname" class="input-xlarge input-xfat" ms-duplex="modelData.Title" data-rules="required" maxlength="200">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            广告图片(750*340)：
        </label>
        <div class="controls" style="width:900px">
            <ul class="sui-row-fluid" id="layer-photos-demo">
                <li class="span2" ms-repeat-el="FileData">
                    <div class="img-round">
                        <img ms-attr-layer-src="{{ComFunJS.FilePath(el)}}" ms-attr-data-id="el.ID" ms-attr-src="ComFunJS.FilePath(el,'/100/100')" alt="">
                    </div>
                    <label>
                        <label> <a href="javascript:void(0);" class="sui-btn btn-bordered btn-small btn-danger" ms-click="DelFile(el)">删除</a> </label>
                    </label>
                </li>
                <li class="span2">
                    <button ms-click="FileUpload()" style="margin:15px 0" class="sui-btn btn-xlarge btn-success">添加图片</button>
                </li>
            </ul>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            链接：
        </label>
        <div class="controls">
            <input type="text" name="phone" class="input-xlarge input-xfat" ms-duplex="modelData.LinkUrl">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            排序：
        </label>
        <div class="controls">
            <input type="text" class="input-medium input-xfat" ms-duplex="modelData.Sort">
        </div>
    </div>
    <div id="timerange" class="control-group input-daterange">
        <label class="control-label">显示时间：</label>
        <div class="controls">
            <input type="text" class="input-medium input-date" data-toggle='datepicker' ms-duplex="modelData.StartDate">
            <span>-</span>
            <input type="text" class="input-medium input-date" data-toggle='datepicker' ms-duplex="modelData.EndDate">
        </div>
    </div>
    <div class="control-group">
        <label class="control-label v-top">
            详情：
        </label>
        <div class="controls">
            <textarea id="txtDetails" class="input-xxlarge bw_ueditor" rows="5" ms-duplex="modelData.Details"></textarea>
        </div>
    </div>
</div>



<script type="text/javascript">
    var tempmodel = avalon.define({
        $id: "tmpmodelview",
        modelData: { "Client": "0", "Type1": "1", "Type2": "", "Title": "", "ImgUrl": "", "Details": "", "LinkUrl": "", "Sort": "1", "StartDate": ComFunJS.getNowDate("yyyy-MM-dd"), "EndDate": "" },
        ClientList: [],
        CatData1: [],
        Init: function (ID) {
            $.getJSON("/adapi/base/client/list", function (r) {
                if (r.error == "") {
                    tempmodel.ClientList = r.result;
                }

            })

            if (ID) {
                $.getJSON("/adapi/advert/model/" + ID, function (r) {
                    if (r.error == "") {
                        tempmodel.modelData = r.result;
                        if (tempmodel.modelData.StartDate) {
                            tempmodel.modelData.StartDate = tempmodel.modelData.StartDate.substring(0, 10);
                        }
                        if (tempmodel.modelData.EndDate) {
                            tempmodel.modelData.EndDate = tempmodel.modelData.EndDate.substring(0, 10);
                        }
                        pmodel.FileData = r.result.ImgUrl.split(',');
                        setTimeout("ComFunJS.initForm();", 500);
                    }

                })
            } else {
                ComFunJS.initForm()
            }
        },
        tmpSaveData: function () {
            tempmodel.modelData.ImgUrl = pmodel.GetFileIds();
            $.post("/adapi/advert/add", tempmodel.modelData.$model, function (r) {
                if (r.error == "") {
                    top.ComFunJS.winShowMsg("操作成功");
                    top.ComFunJS.close();
                } else {
                    top.ComFunJS.winShowAlert(r.error);
                }

            })
        }

    });


</script>




